<?php
require(dirname(__FILE__) .'/check.php');
$skin->CheckIframe();


/* **** 版权所有 ****

 程序开发：网钛科技
 网钛CMS官网：http://otcms.com
 网钛IDC官网：http://idccms.com
 ＱＱ：877873666
 微信：tudougeaini
 邮箱：877873666@qq.com

 **** 版权所有 **** */


//打开用户表，并检测用户是否登录
$MB->Open('','login');

$skin->WebTop();


echo('
<script language="javascript" type="text/javascript" src="js/inc/list.js?v='. OT_VERSION .'"></script>
<script language="javascript" type="text/javascript" src="js/inc/trim.js?v='. OT_VERSION .'"></script>
<script language="javascript" type="text/javascript" src="js/idcProData.js?v='. OT_VERSION .'"></script>
');


switch ($mudi){
	case 'add':
		$MB->IsSecMenuRight('alertBack',9,$dataType);
		AddOrRev();
		break;

	case 'rev':
		$MB->IsSecMenuRight('alertBack',10,$dataType);
		AddOrRev();
		break;

	case 'manage':
		$MB->IsSecMenuRight('alertBack',51,$dataType);
		manage();
		break;

	default:
		die('err');
}

$skin->WebBottom();

$MB->Close();
$DB->Close();





// 新增、修改
function AddOrRev(){
	global $DB,$MB,$skin,$mudi,$dataType,$dataTypeCN;

	$mudi2			= OT::GetStr('mudi2');
	$dataMode		= OT::GetStr('dataMode');
	$dataModeStr	= OT::GetStr('dataModeStr');
	$backURL		= OT::GetStr('backURL');
	$dataID			= OT::GetInt('dataID');
	
	$idcSysArr = Cache::PhpFile('idcProSys');

	if ($mudi=='rev'){
		$revexe=$DB->query('select * from '. OT_dbPref .'idcProData where IPD_ID='. $dataID);
			if (! $row = $revexe->fetch()){
				JS::AlertBackEnd('无该记录！');		
			}
		$IPD_ID			= $row['IPD_ID'];
		$IPD_time		= $row['IPD_time'];
		$IPD_typeStr	= $row['IPD_typeStr'];
		$IPD_type1ID	= $row['IPD_type1ID'];
		$IPD_type2ID	= $row['IPD_type2ID'];
		$IPD_type3ID	= $row['IPD_type3ID'];
		$IPD_groupID	= $row['IPD_groupID'];
		$IPD_theme		= $row['IPD_theme'];
		$IPD_themeStyle	= $row['IPD_themeStyle'];
		$IPD_field1		= $row['IPD_field1'];
		$IPD_field2		= $row['IPD_field2'];
		$IPD_field3		= $row['IPD_field3'];
		$IPD_field4		= $row['IPD_field4'];
		$IPD_field5		= $row['IPD_field5'];
		$IPD_field6		= $row['IPD_field6'];
		$IPD_field7		= $row['IPD_field7'];
		$IPD_field8		= $row['IPD_field8'];
		$IPD_field9		= $row['IPD_field9'];
		$IPD_field10	= $row['IPD_field10'];
		$IPD_field11	= $row['IPD_field11'];
		$IPD_field12	= $row['IPD_field12'];
		$IPD_field1Style	= $row['IPD_field1Style'];
		$IPD_field2Style	= $row['IPD_field2Style'];
		$IPD_field3Style	= $row['IPD_field3Style'];
		$IPD_field4Style	= $row['IPD_field4Style'];
		$IPD_field5Style	= $row['IPD_field5Style'];
		$IPD_field6Style	= $row['IPD_field6Style'];
		$IPD_field7Style	= $row['IPD_field7Style'];
		$IPD_field8Style	= $row['IPD_field8Style'];
		$IPD_field9Style	= $row['IPD_field9Style'];
		$IPD_field10Style	= $row['IPD_field10Style'];
		$IPD_field11Style	= $row['IPD_field11Style'];
		$IPD_field12Style	= $row['IPD_field12Style'];
		$IPD_priceMode	= $row['IPD_priceMode'];
		$IPD_priceDiy	= $row['IPD_priceDiy'];
		$IPD_priceDay	= $row['IPD_priceDay'];
		$IPD_priceWeek	= $row['IPD_priceWeek'];
		$IPD_priceMonth	= $row['IPD_priceMonth'];
		$IPD_price3Month= $row['IPD_price3Month'];
		$IPD_price6Month= $row['IPD_price6Month'];
		$IPD_priceYear	= $row['IPD_priceYear'];
		$IPD_priceOri	= $row['IPD_priceOri'];
		$IPD_proType	= $row['IPD_proType'];
		$IPD_proID		= $row['IPD_proID'];
		$IPD_goUrl		= $row['IPD_goUrl'];
		$IPD_goWapUrl	= $row['IPD_goWapUrl'];
		$IPD_rank		= $row['IPD_rank'];
		$IPD_state		= $row['IPD_state'];
		$IPD_wapState	= $row['IPD_wapState'];

		$mudiCN = '修改';
		$submitCN = '修 改';
	}else{
		if ($dataID>0){
			$revexe=$DB->query('select * from '. OT_dbPref .'idcProData where IPD_ID='. $dataID);
			if ($row = $revexe->fetch()){
				$IPD_typeStr		= $row['IPD_typeStr'];
				$IPD_type1ID		= $row['IPD_type1ID'];
				$IPD_type2ID	= $row['IPD_type2ID'];
				$IPD_type3ID	= $row['IPD_type3ID'];
				$IPD_groupID	= $row['IPD_groupID'];
				$IPD_themeStyle	= $row['IPD_themeStyle'];
				if ($mudi2 == 'copy'){
					$IPD_theme	= $row['IPD_theme'];
				}else{
					$IPD_theme	= '';
				}
				$IPD_field1		= $row['IPD_field1'];
				$IPD_field2		= $row['IPD_field2'];
				$IPD_field3		= $row['IPD_field3'];
				$IPD_field4		= $row['IPD_field4'];
				$IPD_field5		= $row['IPD_field5'];
				$IPD_field6		= $row['IPD_field6'];
				$IPD_field7		= $row['IPD_field7'];
				$IPD_field8		= $row['IPD_field8'];
				$IPD_field9		= $row['IPD_field9'];
				$IPD_field10	= $row['IPD_field10'];
				$IPD_field11	= $row['IPD_field11'];
				$IPD_field12	= $row['IPD_field12'];
				$IPD_field1Style	= $row['IPD_field1Style'];
				$IPD_field2Style	= $row['IPD_field2Style'];
				$IPD_field3Style	= $row['IPD_field3Style'];
				$IPD_field4Style	= $row['IPD_field4Style'];
				$IPD_field5Style	= $row['IPD_field5Style'];
				$IPD_field6Style	= $row['IPD_field6Style'];
				$IPD_field7Style	= $row['IPD_field7Style'];
				$IPD_field8Style	= $row['IPD_field8Style'];
				$IPD_field9Style	= $row['IPD_field9Style'];
				$IPD_field10Style	= $row['IPD_field10Style'];
				$IPD_field11Style	= $row['IPD_field11Style'];
				$IPD_field12Style	= $row['IPD_field12Style'];
				$IPD_priceMode	= $row['IPD_priceMode'];
				$IPD_priceDiy	= $row['IPD_priceDiy'];
				$IPD_priceDay	= $row['IPD_priceDay'];
				$IPD_priceWeek	= $row['IPD_priceWeek'];
				$IPD_priceMonth	= $row['IPD_priceMonth'];
				$IPD_price3Month= $row['IPD_price3Month'];
				$IPD_price6Month= $row['IPD_price6Month'];
				$IPD_priceYear	= $row['IPD_priceYear'];
				$IPD_priceOri	= $row['IPD_priceOri'];
				$IPD_proType	= $row['IPD_proType'];
				$IPD_proID		= $row['IPD_proID'];
				$IPD_goUrl		= $row['IPD_goUrl'];
				$IPD_goWapUrl	= $row['IPD_goWapUrl'];
				$IPD_state		= $row['IPD_state'];
				$IPD_wapState	= $row['IPD_wapState'];
			}
			$dataID = 0;
		}else{
			$IPD_ID			= 0;
			$IPD_time		= '';
			$IPD_typeStr	= '';
			$IPD_type1ID	= 0;
			$IPD_type2ID	= 0;
			$IPD_type3ID	= 0;
			$IPD_groupID	= 0;
			$IPD_theme		= '';
			$IPD_themeStyle	= '';
			$IPD_field1		= '';
			$IPD_field2		= '';
			$IPD_field3		= '';
			$IPD_field4		= '';
			$IPD_field5		= '';
			$IPD_field6		= '';
			$IPD_field7		= '';
			$IPD_field8		= '';
			$IPD_field9		= '';
			$IPD_field10	= '';
			$IPD_field11	= '';
			$IPD_field12	= '';
			$IPD_field1Style	= '';
			$IPD_field2Style	= '';
			$IPD_field3Style	= '';
			$IPD_field4Style	= '';
			$IPD_field5Style	= '';
			$IPD_field6Style	= '';
			$IPD_field7Style	= '';
			$IPD_field8Style	= '';
			$IPD_field9Style	= '';
			$IPD_field10Style	= '';
			$IPD_field11Style	= '';
			$IPD_field12Style	= '';
			$IPD_priceMode	= 0;
			$IPD_priceDiy	= '';
			$IPD_priceDay	= '';
			$IPD_priceWeek	= '';
			$IPD_priceMonth	= '';
			$IPD_price3Month= '';
			$IPD_price6Month= '';
			$IPD_priceYear	= '';
			$IPD_priceOri	= '';
			$IPD_proType	= '';
			$IPD_proID		= 0;
			$IPD_goUrl		= 'http://';
			$IPD_goWapUrl	= 'http://';
			$IPD_state		= 1;
			$IPD_wapState	= 1;
		}
		$IPD_rank		= intval($DB->GetOne('select max(IPD_rank) from '. OT_dbPref .'idcProData')) + 10;

		$mudiCN = '新增';
		$submitCN = '新 增';
	}

	$themeStyle_color	= Str::GetMark($IPD_themeStyle,'color:',';');
	$themeStyle_b		= Str::GetMark($IPD_themeStyle,'font-weight:',';');

	$moreStr = '';

	if ($mudi=='rev'){
		echo('<div onclick="history.back();" class="font2_1 padd8 pointer">&lt;&lt;&ensp;【返回上级】</div>');
	}

	echo('
	<form id="dealForm" name="dealForm" method="post" action="idcProData_deal.php?mudi='. $mudi .'&nohrefStr=close" onsubmit="return CheckForm()">
	<input type="hidden" id="dataID" name="dataID" value="'. $dataID .'" />
	<input type="hidden" id="dataType" name="dataType" value="'. $dataType .'" />
	<input type="hidden" id="dataTypeCN" name="dataTypeCN" value="'. $dataTypeCN .'" />
	<input type="hidden" id="dataMode" name="dataMode" value="'. $dataMode .'" />
	<input type="hidden" id="dataModeStr" name="dataModeStr" value="'. $dataModeStr .'" />
	<input type="hidden" id="currGroupID" name="currGroupID" value="'. $IPD_groupID .'" />
	<input type="hidden" id="currProID" name="currProID" value="'. $IPD_proID .'" />
	'. Area::BackUrlInput($backURL) .'
	');

	echo('
	<table cellpadding="0" cellspacing="0" summary="" class="padd5td">
	<tr><td class="tabLeftWidth"></td><td></td></tr>
	<tr>
		<td align="right">'. Skin::RedSign() .'标题：</td>
		<td align="left">
			<input type="text" id="theme" name="theme" size="50" style="width:380px;'. $IPD_themeStyle .'" value="'. Str::MoreReplace($IPD_theme,'input') .'" />&ensp;
			'. AppBase::InfoThemeB($themeStyle_b,$themeStyle_color) .'
		</td>
	</tr>
	<tr>
		<td align="right">'. Skin::RedSign() .'类别：</td>
		<td align="left">
			<select id="typeStr" name="typeStr" onchange="LoadFieldInfo()">
			<option value=""></option>
			');
			$typeNum = 0;
			$typeexe=$DB->query('select IPT_ID,IPT_theme from '. OT_dbPref ."idcProType where IPT_state=1 and IPT_level=1 order by IPT_rank ASC");
			while ($row = $typeexe->fetch()){
				$typeNum ++;
				$type2exe=$DB->query('select IPT_ID,IPT_theme from '. OT_dbPref ."idcProType where IPT_state=1 and IPT_level=2 and IPT_fatID=". $row['IPT_ID'] ." order by IPT_rank ASC");
				// if (! $row2 = $type2exe->fetch()){
					echo('<option value=",'. $row['IPT_ID'] .'," '. Is::InstrSelected($IPD_typeStr,','. $row['IPT_ID'] .',') .'>'. $typeNum .'、'. $row['IPT_theme'] .'</option>');
				// }else{
				//	echo('<optgroup label="'. $typeNum .'、'. $row['IPT_theme'] .'" style="font-weight:normal;"></optgroup>');
					while ($row2 = $type2exe->fetch()){
						echo('<option value=",'. $row['IPT_ID'] .','. $row2['IPT_ID'] .'," '. Is::InstrSelected($IPD_typeStr,','. $row2['IPT_ID'] .',') .'>&ensp;&ensp;&ensp;┣&ensp;'. $row2['IPT_theme'] .'</option>');
					}
				// }
			}
			echo('
			</select>&ensp;
			&ensp;&ensp;'. $skin->TishiBox('如果有二级类别,一级类别不能选择') .'
		</td>
	</tr>
	<tr>
		<td align="right">'. Skin::RedSign() .'组：</td>
		<td align="left">
			<select id="groupID" name="groupID">
			<option value="">&ensp;&ensp;&ensp;&ensp;</option>
			</select>
		</td>
	</tr>
	<tr>
		<td align="right" valign="top">字段数量：</td>
		<td align="left"><span id="fieldNumStr" style="color:red;">请选择 类别</span><input type="hidden" id="fieldNum" name="fieldNum" value="0" /></td>
	</tr>
	');

	for ($i=1; $i<=12; $i++){
		$fieldVal = 'IPD_field'. $i;
		$fieldStyle = 'IPD_field'. $i .'Style';
		echo('
		<tr id="fieldBox'. $i .'" style="display:none;">
			<td align="right" valign="top"><span class="font1_2d">字段'. $i .'：</span><span id="fieldNameStr'. $i .'"></span></td>
			<td align="left">
				<input type="text" id="field'. $i .'" name="field'. $i .'" size="50" style="width:300px;'. $$fieldStyle .'" value="'. Str::MoreReplace($$fieldVal,'input') .'" />
				'. AdmArea::StyleInput('field'. $i, $$fieldStyle) .'
				<select onchange="$id(\'field'. $i .'\').value = this.value">
					<option value="">备选项</option>
					');
					$opArr = explode(PHP_EOL, $idcSysArr['IPS_optionNote'. $i]);
					foreach ($opArr as $val){
						if (strlen($val) > 0){ echo('<option value="'. $val .'">'. $val .'</option>'); }
					}
				echo('
				</select>
			</td>
		</tr>
		');
	}

	echo('
	<tr>
		<td align="right">价格模式：</td>
		<td align="left">
			<label><input type="radio" id="priceMode0" name="priceMode" value="0" '. Is::Checked($IPD_priceMode,0) .' onclick="CheckPriceMode()" />默认</label>&ensp;&ensp;
			<label><input type="radio" id="priceMode1" name="priceMode" value="1" '. Is::Checked($IPD_priceMode,1) .' onclick="CheckPriceMode()" />自编辑</label>&ensp;&ensp;
			<label><input type="radio" id="priceMode2" name="priceMode" value="2" '. Is::Checked($IPD_priceMode,2) .' onclick="CheckPriceMode()" />选择产品</label>&ensp;&ensp;
		</td>
	</tr>
	<tbody id="priceMode0Box">
	<tr id="priceDayBox" style="display:none;">
		<td align="right">日付：</td>
		<td align="left">
			<input type="text" id="priceDay" name="priceDay" size="50" style="width:80px;" value="'. $IPD_priceDay .'" />
		</td>
	</tr>
	<tr id="priceWeekBox" style="display:none;">
		<td align="right">周付：</td>
		<td align="left">
			<input type="text" id="priceWeek" name="priceWeek" size="50" style="width:80px;" value="'. $IPD_priceWeek .'" />
		</td>
	</tr>
	<tr id="priceMonthBox" style="display:none;">
		<td align="right">月付：</td>
		<td align="left">
			<input type="text" id="priceMonth" name="priceMonth" size="50" style="width:80px;" value="'. $IPD_priceMonth .'" />
		</td>
	</tr>
	<tr id="price3MonthBox" style="display:none;">
		<td align="right">季付：</td>
		<td align="left">
			<input type="text" id="price3Month" name="price3Month" size="50" style="width:80px;" value="'. $IPD_price3Month .'" />
		</td>
	</tr>
	<tr id="price6MonthBox" style="display:none;">
		<td align="right">半年付：</td>
		<td align="left">
			<input type="text" id="price6Month" name="price6Month" size="50" style="width:80px;" value="'. $IPD_price6Month .'" />
		</td>
	</tr>
	<tr id="priceYearBox" style="display:none;">
		<td align="right">年付：</td>
		<td align="left">
			<input type="text" id="priceYear" name="priceYear" size="50" style="width:80px;" value="'. $IPD_priceYear .'" />
		</td>
	</tr>
	<tr id="priceOriBox" style="display:none;">
		<td align="right">原价：</td>
		<td align="left">
			<input type="text" id="priceOri" name="priceOri" size="50" style="width:80px;" value="'. $IPD_priceOri .'" />
		</td>
	</tr>
	</tbody>
	<tbody id="priceMode1Box" style="display:none;">
	<tr>
		<td align="right" valign="top">'. Skin::RedSign() .'自编辑价格：</td>
		<td>
			<textarea id="priceDiy" name="priceDiy" cols="40" rows="4" style="width:510px;height:60px;" class="text" onclick=\'LoadEditor("priceDiy",510,60,"|miniMenu|");\' title="点击开启编辑器模式">'. Str::MoreReplace($IPD_priceDiy,'textarea') .'</textarea>
		</td>
	</tr>
	</tbody>
	<tbody id="priceMode2Box" style="display:none;">
	<tr>
		<td align="right">'. Skin::RedSign() .'产品类型：</td>
		<td align="left">
			<select id="proType" name="proType" onchange="LoadProTypeInfo()">
			<option value=""></option>
			'. (AppHost::Jud() ? '<option value="host" '. Is::Selected($IPD_proType,'host') .'>虚拟主机</option>' : '') .'
			<option value="vps" '. Is::Selected($IPD_proType,'vps') .'>云服务器</option>
			</select>
		</td>
	</tr>
	<tr>
		<td align="right">'. Skin::RedSign() .'产品ID：</td>
		<td align="left">
			<select id="proID" name="proID">
			<option value="" style="color:#c9c9c9;">先选择 产品类型</option>
			</select>
		</td>
	</tr>
	</tbody>
	<tbody id="goUrlBox">
	<tr>
		<td align="right" valign="top" style="padding-top:6px;">开通PC版购买网址：</td>
		<td align="left">
			<input type="text" id="goUrl" name="goUrl" size="50" style="width:520px;" value="'. $IPD_goUrl .'" />
			<div style="padding:1px 0;">
				<select onchange="$id(\'goUrl\').value = this.value">
					<option value="">备选项</option>
					');
					$opArr = explode(PHP_EOL, $idcSysArr['IPS_goUrlNote']);
					foreach ($opArr as $val){
						if (strlen($val) > 0){ echo('<option value="'. $val .'">'. $val .'</option>'); }
					}
				echo('
				</select>
			</div>
		</td>
	</tr>
	<tr>
		<td align="right" valign="top" style="padding-top:6px;">开通WAP版购买网址：</td>
		<td align="left">
			<input type="text" id="goWapUrl" name="goWapUrl" size="50" style="width:520px;" value="'. $IPD_goWapUrl .'" />
			<div style="padding:1px 0;">
				<select onchange="$id(\'goWapUrl\').value = this.value">
					<option value="">备选项</option>
					');
					$opArr = explode(PHP_EOL, $idcSysArr['IPS_goWapUrlNote']);
					foreach ($opArr as $val){
						if (strlen($val) > 0){ echo('<option value="'. $val .'">'. $val .'</option>'); }
					}
				echo('
				</select>
			</div>
		</td>
	</tr>
	</tbody>
	<tr>
		<td align="right">排序：</td>
		<td align="left"><input type="text" id="rank" name="rank" size="50" style="width:30px;" value="'. $IPD_rank .'" /></td>
	</tr>
	<tr>
		<td align="right">电脑版状态：</td>
		<td align="left">
			<label><input type="radio" name="state" value="1" '. Is::Checked($IPD_state,1) .' />显示</label>&ensp;&ensp;
			<label><input type="radio" name="state" value="0" '. Is::Checked($IPD_state,0) .' />隐藏</label>&ensp;&ensp;
		</td>
	</tr>
	<tr>
		<td align="right">手机版状态：</td>
		<td align="left">
			<label><input type="radio" name="wapState" value="1" '. Is::Checked($IPD_wapState,1) .' />显示</label>&ensp;&ensp;
			<label><input type="radio" name="wapState" value="0" '. Is::Checked($IPD_wapState,0) .' />隐藏</label>&ensp;&ensp;
		</td>
	</tr>
	</table>

	<table style="height:16px;" cellpadding="0" cellspacing="0" summary=""><tr><td></td></tr></table>

	<center><input type="image" src="'. AdmTpl::ImgSrc('button_'. $mudi) .'" /></center>

	</form>
	');
}



// 管理
function manage(){
	global $DB,$MB,$skin,$mudi,$dataType,$dataTypeCN,$pageCount,$recordCount;

	$dataMode		= OT::GetStr('dataMode');
	$dataModeStr	= OT::GetStr('dataModeStr');

	$refTypeStr		= OT::GetStr('refTypeStr');
		if ($refTypeStr != ''){ $refTypeStr=','. Str::RegExp($refTypeStr,'sql') .','; }
	$refFieldNum	= OT::GetInt('refFieldNum');
		if ($refFieldNum < 1 || $refFieldNum > 12){ $refFieldNum = 1; }
	$refFieldVal	= OT::GetRegExpStr('refFieldVal','sql');
	$refState		= OT::GetInt('refState',-1);
	$refWapState	= OT::GetInt('refWapState',-1);
	$refTheme		= OT::GetRegExpStr('refTheme','sql');
	$refDate1		= OT::GetStr('refDate1');
		if (! strtotime($refDate1)){ $refDate1=''; }
	$refDate2		= OT::GetStr('refDate2');
		if (! strtotime($refDate2)){ $refDate2=''; }

	$SQLstr='select * from '. OT_dbPref .'idcProData where 1=1';

	if ($refTypeStr != ''){
		if (strpos($refTypeStr,',group') !== false){
			$SQLstr .= " and IPD_groupID=". intval(str_replace(array(',group',','), array('',''), $refTypeStr));
		}else{
			$SQLstr .= " and IPD_typeStr like '%". $DB->ForStr($refTypeStr,false) ."%'";
		}
	}
	if ($refFieldVal != ''){ $SQLstr .= " and IPD_field". $refFieldNum ." like '%". $DB->ForStr($refFieldVal,false) ."%'"; }
	if ($refState > -1){ $SQLstr .= ' and IPD_state='. $refState; }
	if ($refWapState > -1){ $SQLstr .= ' and IPD_wapState='. $refWapState; }
	if ($refTheme != ''){ $SQLstr .= " and IPD_theme like '%". $DB->ForStr($refTheme,false) ."%'"; }
	if ($refDate1 != ''){ $SQLstr .= ' and IPD_time>='. $DB->ForTime($refDate1); }
	if ($refDate2 != ''){ $SQLstr .= ' and IPD_time<='. $DB->ForTime(TimeDate::Add('d',1,$refDate2)); }

	$orderName = OT::ListDefVal(OT::GetStr('orderName'), 'IPD_theme|IPD_typeStr|IPD_state|IPD_wapState|IPD_time|IPD_ID|IPD_rank', 'IPD_rank');
	$orderSort = OT::ListDefVal(OT::GetStr('orderSort'), 'ASC', 'DESC');

	echo('
	<div class="padd5">
		<input type="button" value="新增'. $dataTypeCN .'" onclick=\'document.location.href="?mudi=add&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&dataMode='. $dataMode .'&dataModeStr='. $dataModeStr .'&backURL="+ encodeURIComponent(document.location.href)\' />&ensp;&ensp;
		<input type="button" value="备选项设置" onclick=\'document.location.href="idcProSys.php?mudi=infoSet&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&dataMode='. $dataMode .'&dataModeStr='. $dataModeStr .'&backURL="+ encodeURIComponent(document.location.href)\' />
	</div>
	');

	$skin->TableTop('share_refer.gif','',$dataTypeCN .'查询');
		echo('
		<form id="refForm" name="refForm" method="get" action="">
		<input type="hidden" name="mudi" value="'. $mudi .'" />
		<input type="hidden" name="dataMode" value="'. $dataMode .'" />
		<input type="hidden" name="dataModeStr" value="'. $dataModeStr .'" />
		<input type="hidden" name="dataType" value="'. $dataType .'" />
		<input type="hidden" name="dataTypeCN" value="'. $dataTypeCN .'" />

		<table width="98%" align="center" border="0" cellSpacing="0" cellPadding="0" summary="" class="padd5">
		<tr>
			<td style="width:32%;">
				类别：<select id="refTypeStr" name="refTypeStr" style="width:180px;">
					<option value=""></option>
					');
					$typeNum = 0;
					$typeexe=$DB->query('select IPT_ID,IPT_theme,IPT_state from '. OT_dbPref .'idcProType where IPT_level=1 order by IPT_rank ASC');
					while ($row = $typeexe->fetch()){
						$typeNum ++;
						$stateStyle = $stateStr = '';
						if ($row['IPT_state'] == 0){
							$stateStyle = ' style="color:#c9c9c9;;"';
							$stateStr = '（隐藏）';
						}
						echo('<option value="'. $row['IPT_ID'] .'" '. Is::InstrSelected($refTypeStr,','. $row['IPT_ID'] .',') . $stateStyle .'>'. $typeNum .'、【'. $row['IPT_theme'] .'】'. $stateStr .'</option>');

						$type2exe=$DB->query('select IPT_ID,IPT_theme,IPT_state from '. OT_dbPref .'idcProType where IPT_level=2 and IPT_fatID='. $row['IPT_ID'] .' order by IPT_rank ASC');
						while ($row2 = $type2exe->fetch()){
							$stateStyle = ' style="color:blue;"';
							$stateStr = '';
							if ($row2['IPT_state'] == 0){
								$stateStyle = ' style="color:#c9c9c9;;"';
								$stateStr = '（隐藏）';
							}
							echo('<option value="'. $row2['IPT_ID'] .'" '. Is::Selected($refTypeStr,','. $row2['IPT_ID'] .',') . $stateStyle .'>&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;【'. $row2['IPT_theme'] .'】'. $stateStr .'</option>');

							$show3exe=$DB->query('select * from '. OT_dbPref .'idcProGroup where IPG_type2ID='. $row2['IPT_ID'] .' order by IPG_rank ASC');
							while ($row3 = $show3exe->fetch()){
								echo('<option value="group'. $row3['IPG_ID'] .'" '. Is::Selected($refTypeStr,',group'. $row3['IPG_ID'] .',') .'>&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;┗&ensp;'. $row3['IPG_theme'] .'</option>');
							}
							unset($show3exe);
						}
					}
					echo('
					</select>&ensp;
			</td>
			<td style="width:28%;">
				<select id="refFieldNum" name="refFieldNum">
					<!-- <option value=""></option> -->
					<option value="1" '. Is::Selected($refFieldNum,1) .'>字段1</option>
					<option value="2" '. Is::Selected($refFieldNum,2) .'>字段2</option>
					<option value="3" '. Is::Selected($refFieldNum,3) .'>字段3</option>
					<option value="4" '. Is::Selected($refFieldNum,4) .'>字段4</option>
					<option value="5" '. Is::Selected($refFieldNum,5) .'>字段5</option>
					<option value="6" '. Is::Selected($refFieldNum,6) .'>字段6</option>
					<option value="7" '. Is::Selected($refFieldNum,7) .'>字段7</option>
					<option value="8" '. Is::Selected($refFieldNum,8) .'>字段8</option>
					<option value="9" '. Is::Selected($refFieldNum,9) .'>字段9</option>
					<option value="10" '. Is::Selected($refFieldNum,10) .'>字段10</option>
					<option value="11" '. Is::Selected($refFieldNum,11) .'>字段11</option>
					<option value="12" '. Is::Selected($refFieldNum,12) .'>字段12</option>
					</select>
					<input type="text" name="refFieldVal" size="14" style="width:100px;" value="'. $refFieldVal .'" />
			</td>
			<td style="width:40%;">
				电脑状态：<select id="refState" name="refState">
					<option value=""></option>
					<option value="1" '. Is::Selected($refState,1) .'>显示</option>
					<option value="0" '. Is::Selected($refState,0) .'>隐藏</option>
					</select>
				/&ensp;WAP状态：<select id="refWapState" name="refWapState">
					<option value=""></option>
					<option value="1" '. Is::Selected($refWapState,1) .'>显示</option>
					<option value="0" '. Is::Selected($refWapState,0) .'>隐藏</option>
					</select>
			</td>
		</tr>
		<tr>
			<td>
				标题：<input type="text" name="refTheme" size="20" style="width:175px;" value="'. $refTheme .'" />
			</td>
			<td>
				
			</td>
			<td>
				发布日期：<input type="text" name="refDate1" size="10" style="width:70px;" value="'. $refDate1 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />&ensp;
				至&ensp;<input type="text" name="refDate2" size="10" style="width:70px;" value="'. $refDate2 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />
			</td>
		</tr>
		<tr>
			<td align="center" style="padding:5px;padding-top:20px" colspan="4">
				<input type="image" src="'. AdmTpl::ImgSrc('button_refer') .'" />
				&ensp;&ensp;&ensp;&ensp;
				<img src="'. AdmTpl::ImgSrc('button_reset') .'" onclick=\'document.location.href="?mudi='. $mudi .'&dataMode='. $dataMode .'&dataModeStr='. $dataModeStr .'&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'"\' style="cursor:pointer" alt="" />
			</td>
		</tr>
		</table>
		</form>
		');
	$skin->TableBottom();

	echo('
	<br />

	<form id="listForm" name="listForm" method="post" action="idcProData_deal.php?mudi=moreDel" onsubmit="return CheckListForm()">
	<script language="javascript" type="text/javascript">document.write (\'<input type="hidden" name="backURL" value="\'+ document.location.href +\'" />\')</script>
	<input type="hidden" name="dataType" value="'. $dataType .'" />
	<input type="hidden" name="dataTypeCN" value="'. $dataTypeCN .'" />
	');

	$skin->TableTop2('share_list.gif','',$dataTypeCN .'列表');
	$skin->TableItemTitle('4%,4%,5%,16%,17%,5%,4%,8%,11%,10%','<input type="checkbox" id="selAll" name="selAll" onclick="CheckBoxAll()" />,序号,'. $skin->ShowArrow('ID','IPD_ID',$orderName,$orderSort) .','. $skin->ShowArrow('标题','IPD_theme',$orderName,$orderSort) .',类别/组,价格,'. $skin->ShowArrow('排序','IPD_rank',$orderName,$orderSort) .','. $skin->ShowArrow('电脑','IPD_state',$orderName,$orderSort) .'/'. $skin->ShowArrow('WAP状态','IPD_wapState',$orderName,$orderSort) .','. $skin->ShowArrow('添加日期','IPD_time',$orderName,$orderSort) .',复制&ensp;修改&ensp;删除');

	$pageSize	= $MB->mMbRow['MB_itemNum'];		//每页条数
	$page		= OT::GetInt('page');
	$showRow=$DB->GetLimit($SQLstr .' order by '. $orderName .' '. $orderSort .'',$pageSize,$page);
	if (! $showRow){
		$skin->TableNoData();
	}else{
		$recordCount=$DB->GetRowCount();
		$pageCount=ceil($recordCount/$pageSize);
		if ($page < 1 || $page > $pageCount){$page=1;}

		$idcProType = new IdcProType();
		echo('
		<tbody class="tabBody padd3td">
		');
		$number=1+($page-1)*$pageSize;
		$rowCount = count($showRow);
		for ($i=0; $i<$rowCount; $i++){
			if ($i % 2 == 1){ $bgcolor='class="tabColorTr"'; }else{ $bgcolor=''; }
			echo('
			<tr '. $bgcolor .' id="data'. $showRow[$i]['IPD_ID'] .'">
				<td align="center" class="selCheckbox"><input type="checkbox" name="selDataID[]" value="'. $showRow[$i]['IPD_ID'] .'" /></td>
				<td align="center">'. $number .'</td>
				<td align="center">'. $showRow[$i]['IPD_ID'] .'</td>
				<td align="left" style="word-break:break-all;'. $showRow[$i]['IPD_themeStyle'] .'">'. $showRow[$i]['IPD_theme'] .'</td>
				<td align="left">
					'. $idcProType->TypeStrCN($showRow[$i]['IPD_typeStr'],'&ensp;-&ensp;') .'
					<div style="color:blue;">'. $DB->GetOne('select IPG_theme from '. OT_dbPref .'idcProGroup where IPG_ID='. $showRow[$i]['IPD_groupID']) .'</div>
				</td>
				<td align="left">'. PriceList($showRow[$i]['IPD_priceMode'], $showRow[$i]['IPD_priceDay'], $showRow[$i]['IPD_priceWeek'], $showRow[$i]['IPD_priceMonth'], $showRow[$i]['IPD_price3Month'], $showRow[$i]['IPD_price6Month'], $showRow[$i]['IPD_priceYear'], $showRow[$i]['IPD_proType'], $showRow[$i]['IPD_proID']) .'</td>
				<td align="center">'. $showRow[$i]['IPD_rank'] .'</td>
				<td align="center">
					'. Adm::SwitchBtn('idcProData',$showRow[$i]['IPD_ID'],$showRow[$i]['IPD_state'],'state') .'/
					'. Adm::SwitchBtn('idcProData',$showRow[$i]['IPD_ID'],$showRow[$i]['IPD_wapState'],'wapState','userState') .'
				</td>
				<td align="center">'. $showRow[$i]['IPD_time'] .'</td>
				<td align="center">
					<img src="images/img_copy.gif" class="pointer" onclick=\'document.location.href="?mudi=add&mudi2=copy&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&dataMode='. $dataMode .'&dataModeStr='. $dataModeStr .'&dataID='. $showRow[$i]['IPD_ID'] .'&backURL="+ encodeURIComponent(document.location.href)\' alt="复制" title="复制" />&ensp;&ensp;
					<img src="images/img_rev.gif" class="pointer" onclick=\'document.location.href="?mudi=rev&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&dataMode='. $dataMode .'&dataModeStr='. $dataModeStr .'&dataID='. $showRow[$i]['IPD_ID'] .'&backURL="+ encodeURIComponent(document.location.href)\' alt="修改" title="修改" />&ensp;&ensp;
					<img src="images/img_del.gif" class="pointer" onclick=\'if(confirm("你确定要删除？")==true){DataDeal.location.href="idcProData_deal.php?mudi=del&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&theme='. urlencode($showRow[$i]['IPD_theme']) .'&dataID='. $showRow[$i]['IPD_ID'] .'"}\' alt="删除" title="删除" />
				</td>
			</tr>
			');
			$number ++;
		}
		echo('
		</tbody>
		<tr class="tabColorB padd5">
			<td align="left" colspan="20">
				<input type="button" value="全选" onclick="AllSelBox()" class="form_button1" />
				<input type="button" value="反选" onclick="RevSelBox()" class="form_button1" />
				&ensp;
				<input type="submit" value="批量删除" />
			</td>
		</tr>
		');
	}
	unset($showRow);

	echo('</form>');

	$skin->TableBottom2($pageCount, $pageSize, $recordCount);
}


function PriceList($mode,$day,$week,$month,$month3,$month6,$year,$proType,$proID){
	if ($mode == 1){
		return '自编辑';
	}elseif ($mode == 2){
		return '产品<br />'. $proType . $proID;
	}else{
		$retStr = '';
		if ($day > 0){ $retStr = '<div>日：'. floatval($day) .'</div>'; }
		if ($week > 0){ $retStr = '<div>周：'. floatval($week) .'</div>'; }
		if ($month > 0){ $retStr = '<div>月：'. floatval($month) .'</div>'; }
		if ($month3 > 0){ $retStr = '<div>3月：'. floatval($month3) .'</div>'; }
		if ($month6 > 0){ $retStr = '<div>半年：'. floatval($month6) .'</div>'; }
		if ($year > 0){ $retStr = '<div>年：'. floatval($year) .'</div>'; }
		return $retStr;
	}
}
?>